<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="bootstrap-3.3.7-dist/css/bootstrap.css"/>
</head>
<body>
	<a class="btn btn-primary" href="${pageContext.request.contextPath}/student_insert.jsp">添加</a>
	<table class="table table-hover table-bordered">
		<tr>
			<td>ID</td>
			<td>名字</td>
			<td>年龄</td>
			<td>性别</td>
			<td>删除</td>
			<td>修改</td>
		</tr>
		<c:forEach items="${list}" var="student">
			<tr>
				<td>${student.id}</td>
				<td>${student.name}</td>
				<td>${student.age}</td>
				<td>${student.gender}</td>
				<td><a onclick="deleteById(${student.id})" href="javascript:void(0)">删除</a></td>
				<td><a href="${pageContext.request.contextPath}/student?method=getStudentUpdatePage&id=${student.id}">修改</a></td>
			</tr>
		</c:forEach>
	</table>
	
	<script type="text/javascript">
		function deleteById(id) {
			var isDelete = confirm("您确认要删除么？");
			if(isDelete) {
				location.href = "${pageContext.request.contextPath}/student?method=deleteById&id=" + id;
			}
		}
	</script>
</body>
</html>